﻿using Gasgoo.DataProvider.SqlSugar.Logger;
using Gasgoo.ShareLibrary.Framework.Global;
using Gasgoo.ShareLibrary.Framework.ServiceDefine;
using IToolLogger.Interface;
using Microsoft.Extensions.Logging;
using Orleans.Providers;
using SqlSugar;

namespace IToolLoggerService;


//[StorageProvider(ProviderName = Constants.DATA_ENTITY_PROVIDER)]
[StorageProvider(ProviderName = Constants.DATA_SUGAR_PROVIDER)]
public class LogFunctionService : GasgooServiceBase<LogFunction>, ILogFunctionService
{
    public LogFunctionService(ILogger<LogFunctionService> logger)
    {
        Logger = logger;
    }

    public ILogger<LogFunctionService> Logger { get; }

    public Task<LogFunction> GetLogFunctionAsync()
    {
        this.Logger.LogError("就是记录一下错误");
        return Task.FromResult(this.State);
    }

    public async Task ModifyAsync()
    {
        this.State.Host = this.State.Host + "-";
        await this.WriteStateAsync();
    }

    public async Task<List<LogFunction>> QueryAsync()
    {
        return await this.State.ToPageListAsync(1,20);
    }

}
